<template>
	<view class="content">
		<u-cell-group :customStyle="{'background-color': '#fff'}">
			<u-cell size="large" title="昵称" :value="real_name"></u-cell>
			<u-cell size="large" title="账号" :value="user_name"></u-cell>
			<u-cell size="large" title="电话" :value="mobile_phone"></u-cell>
		</u-cell-group>
		<!-- remove -->
		<view class="btn_box">
			<u-button @click="handleOut" color="#232773" customStyle="margin: 10px 0">
				退 出 登 录
			</u-button>
		</view>
	</view>
</template>

<script>
	import {
		getPage,
		getImage
	} from '../../utils/config';
	import {
		imageCdn
	} from '../../utils/api';
	import {
		prosimify,
		$toast,
		http,
		storage
	} from '../../utils/utils';
	import wxApi from '../../utils/wxApi';
	import api from '../../utils/api';
	const app = getApp();
	export default {
		data() {
			return {
				localInfo: {},
				logged: null,
				real_name: '',
				user_name: '',
				mobile_phone: ''
			}
		},
		onShow() {
			console.log('show___________________111');
			//判断是否登录
			app.globalData
				.getLogin()
				.then((res) => {
					console.log('show__getLogin___then______________', res);
					this.localInfo = res;
					this.logged = res.code;
					let {
						real_name,
						user_name,
						mobile_phone
					} = res.data;
					this.real_name = real_name;
					this.user_name = user_name;
					this.mobile_phone = mobile_phone;
				}).catch((res) => {
					console.log('show__getLogin___catch______________', res);
					this.logged = res
					this.goLogin();
				}).finally(() => {
					this.initial = 1;
				});
		},
		methods: {
			/**
			 * 跳转登录
			 */
			goLogin() {
				console.log('打印-跳转登录~~~')
				wxApi.setStartPage();
				wxApi.navigateTo(getPage.login);
			},
			handleOut() {
				let that = this;
				uni.showModal({
					title: '退出提示',
					content: '确认退出此账号？',
				 success: function(res) {
						if (res.confirm) {
							storage.set('userInfo', {
								code: 0,
								data: ''
							});
							storage.set('regionInfo', []);
							that.goLogin();
						} else if (res.cancel) {
							console.log('用户点击取消');
						}
					}
				});
			}
		}
	}
</script>

<style lang="scss">
	.user_box {
		margin: 100px auto;
		padding: 20px;
		width: 80%;
		border-radius: 25px;
	}

	.btn_box {
		padding: 10rpx 20rpx;
	}
</style>
